Skip to content

Conversation

@Grufoony
Copy link
Collaborator

No description provided.

@Grufoony Grufoony self-assigned this Dec 21, 2024

from argparse import ArgumentParser
import osmnx as ox
import networkx as nx

Check warning

Code scanning / Prospector (reported by Codacy)

Unable to import 'networkx' (import-error) Warning

Unable to import 'networkx' (import-error)
from argparse import ArgumentParser
import osmnx as ox
import networkx as nx
import matplotlib.patches as mpatches

Check warning

Code scanning / Prospector (reported by Codacy)

Unable to import 'matplotlib.patches' (import-error) Warning

Unable to import 'matplotlib.patches' (import-error)
import osmnx as ox
import networkx as nx
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt

Check warning

Code scanning / Prospector (reported by Codacy)

Unable to import 'matplotlib.pyplot' (import-error) Warning

Unable to import 'matplotlib.pyplot' (import-error)
G_ALL = ox.graph_from_place(parser.place, network_type="drive")
print(f"Graph created with {len(G_ALL.nodes)} nodes and {len(G_ALL.edges)} edges.")

gdf_nodes, gdf_edges = ox.graph_to_gdfs(G_ALL)

Check warning

Code scanning / Pylint (reported by Codacy)

Constant name "gdf_nodes" doesn't conform to UPPER_CASE naming style Warning

Constant name "gdf_nodes" doesn't conform to UPPER_CASE naming style
G_ALL = ox.graph_from_place(parser.place, network_type="drive")
print(f"Graph created with {len(G_ALL.nodes)} nodes and {len(G_ALL.edges)} edges.")

gdf_nodes, gdf_edges = ox.graph_to_gdfs(G_ALL)

Check warning

Code scanning / Pylint (reported by Codacy)

Constant name "gdf_edges" doesn't conform to UPPER_CASE naming style Warning

Constant name "gdf_edges" doesn't conform to UPPER_CASE naming style
# gdf_edges = gdf_edges[~gdf_edges["access"].isin(["no", "private"])]

# Make a plot to visualize the removed links
removed_patch = mpatches.Patch(color=RGBA_RED, label="Removed Nodes and Edges")

Check warning

Code scanning / Pylint (reported by Codacy)

Constant name "removed_patch" doesn't conform to UPPER_CASE naming style Warning

Constant name "removed_patch" doesn't conform to UPPER_CASE naming style
removed_patch = mpatches.Patch(color=RGBA_RED, label="Removed Nodes and Edges")

if parser.exclude_motorway:
gdf_edges = gdf_edges[~gdf_edges["highway"].isin(FLAGS_MOTORWAY)]

Check warning

Code scanning / Pylint (reported by Codacy)

Constant name "gdf_edges" doesn't conform to UPPER_CASE naming style Warning

Constant name "gdf_edges" doesn't conform to UPPER_CASE naming style
if parser.exclude_motorway:
gdf_edges = gdf_edges[~gdf_edges["highway"].isin(FLAGS_MOTORWAY)]
if parser.exclude_residential:
gdf_edges = gdf_edges[~gdf_edges["highway"].isin(FLAGS_RESIDENTIAL)]

Check warning

Code scanning / Pylint (reported by Codacy)

Constant name "gdf_edges" doesn't conform to UPPER_CASE naming style Warning

Constant name "gdf_edges" doesn't conform to UPPER_CASE naming style
G.remove_nodes_from(list(nx.isolates(G)))
print(f"Graph filterded: now it has {len(G.nodes)} nodes and {len(G.edges)} edges.")

fig, ax = ox.plot_graph(

Check warning

Code scanning / Pylint (reported by Codacy)

Constant name "fig" doesn't conform to UPPER_CASE naming style Warning

Constant name "fig" doesn't conform to UPPER_CASE naming style
G.remove_nodes_from(list(nx.isolates(G)))
print(f"Graph filterded: now it has {len(G.nodes)} nodes and {len(G.edges)} edges.")

fig, ax = ox.plot_graph(

Check warning

Code scanning / Pylint (reported by Codacy)

Constant name "ax" doesn't conform to UPPER_CASE naming style Warning

Constant name "ax" doesn't conform to UPPER_CASE naming style
std::getline(iss, oneway, ';');
std::getline(iss, lanes, ';');
std::getline(iss, highway, ';');
std::getline(iss, maxspeed, ';');

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.3 rule Note

MISRA 12.3 rule

Id streetId = std::stoul(sourceId) + std::stoul(targetId) * m_nodes.size();
m_streets.emplace(
streetId,

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 17.7 rule Note

MISRA 17.7 rule

Id streetId = std::stoul(sourceId) + std::stoul(targetId) * m_nodes.size();
m_streets.emplace(
streetId,

Check notice

Code scanning / Cppcheck (reported by Codacy)

Return value of function std::stoul() is not used. Note

Return value of function std::stoul() is not used.
std::stoul(lanes),
name);
}
} else {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.3 rule Note

MISRA 12.3 rule
// get number of lines
std::string line;
int nNodes{-1}; // -1 because of the header
while (std::getline(fNodes, line)) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note test

MISRA 14.4 rule
fNodes.close();
std::ifstream fEdges{"./data/edges.csv"};
int nEdges{-1}; // -1 because of the header
while (std::getline(fEdges, line)) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note test

MISRA 14.4 rule
// get number of lines
std::string line;
int nNodes{-1}; // -1 because of the header
while (std::getline(fNodes, line)) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note test

MISRA 14.4 rule
fNodes.close();
std::ifstream fEdges{"./data/edges_big.csv"};
int nEdges{-1}; // -1 because of the header
while (std::getline(fEdges, line)) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note test

MISRA 14.4 rule
@Grufoony Grufoony merged commit 5ce7a4a into main Dec 21, 2024
25 checks passed
@Grufoony Grufoony deleted the better_osmImport branch December 21, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants